﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using CommonTagTime;
using CommonTagTime.ModelObject;
using CommonTagTime.Business;


namespace CommonTagTime.DataAccess
{
    class daoSlideEffect
    {
        public daoSlideEffect()
        {

        }

        public SlideEffect Load(IDataReader de)
        {
            SlideEffect item = new SlideEffect();
            item.SlideEffectId = clsConvert.DbToInt("SlideEffectId", de);
            item.Code = clsConvert.DbToString("Code", de);
            item.Name = clsConvert.DbToString("Name", de);
            item.SortOrder = clsConvert.DbToInt("SortOrder", de);

            return item;
        }

        public SlideEffect GetById(int SlideEffectId)
        {
            clsSQL clsSQL = new clsSQL();
            SlideEffect item = new SlideEffect();
            SqlParameter[] para = new SqlParameter[0];
            SqlDataReader de;
            try
            {
                para[0] = new SqlParameter(busSlideEffect.SlideEffectId, SqlDbType.Int);
                para[0].Value = SlideEffectId;
                de = clsSQL.SPDataReader("SlideEffect_GetById", para);
                while (de.Read())
                {
                    item = Load(de);
                }
                de.Close();
                de.Dispose();
            }
            catch (Exception ex)
            {
                item = null;
                clsFile.WriteLog("daoSlideEffect", " GetByID(int SlideEffectID)", ex.ToString());
            }
            finally
            {
                de = null;                    
                clsSQL.Dispose();
                clsSQL = null;
            }
            return item;
        }

        public SlideEffectCollection GetAll()
        {
            clsSQL clsSQL = new clsSQL();
            SlideEffectCollection items = new SlideEffectCollection();
            SqlDataReader de;
            try
            {
                de = clsSQL.SPDataReader("SlideEffect_GetAll");
                while (de.Read())
                {
                    SlideEffect item = new SlideEffect();
                    item = Load(de);
                    items.Add(item);
                }
                de.Close();
                de.Dispose();

            }
            catch (Exception ex)
            {
                clsFile.WriteLog("daoSlideEffect", " GetAll()", ex.ToString());
            }
            finally
            {
                de = null;
                clsSQL.Dispose();
                clsSQL = null;
            }
            return items;
        }

    }
}
